package com.example.iotmanagerment26.mapper;

import com.example.iotmanagerment26.domain.Data;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 作者：太难猫
 * 创建时间： 2025/6/4 16:20
 */
public interface DataMapper {
    @Insert("insert into data values(null,#{name},#{temperature},#{humidity},#{light},#{time},null)")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    public int insertData(Data data);

    @Select("select * from data where name=#{name} order by time Desc LIMIT 1 ")
    Data selectDataByName(String name);

    @Select("select * from data where name=#{name} order by time Desc LIMIT 10 ")
    List<Data> selectHisDataByName(String name);
}